﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Collections.Specialized;

namespace System.Collections.Observable.DebugViews
{
    class ObservableListBaseDebugView<TValue, TList> where TList : IList<TValue>

    {
        ObservableListBase<TValue, TList> ObservableList;

        [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
        [DebuggerDisplay("{InternalCollection.Count}", Name = "Internal List")]
        public TList InternalCollection
        {
            get
            {
                return ObservableList.InternalCollection;
            }
        }

        [DebuggerDisplay("{SubscribersCount}")]        
        public NotifyCollectionChangedEventHandler Subscribers
        {
            get
            {
                return ObservableList.CollectionChangedSubscribers;
            }
        }

        private int SubscribersCount
        {
            get
            {
                NotifyCollectionChangedEventHandler subscribers = ObservableList.CollectionChangedSubscribers;
                if (subscribers == null)
                {
                    return 0;
                }
                else
                {
                    return subscribers.GetInvocationList().Length;
                }
            }
        }

        public ObservableListBaseDebugView(ObservableListBase<TValue, TList> observableList)
        {
            ObservableList = observableList;
        }
    }
}
